//
//  InputMailView.swift
//  todoios
//
//  Created by qianli on 2025/5/22.
//

import Foundation


class InputMailView: UIView {
    private var pacrUaJmER3vDJE5: UITextField?
    
    deinit {
        QianliUniversalFunc.QianliLog("------InputMailView.deinit")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    init(frame:CGRect,icoName:String,placeholder:String,showclear:Bool){
        super.init(frame: frame)
        self.GHL4Rhb91XYBer27( icoName, placeholder,showclear)
    }
    
    private func GHL4Rhb91XYBer27(_ icoName:String,_ placeholder:String,_ showclear:Bool){
//        let icoView = UIImageView(frame: CGRect(x: 15, y: self.bounds.height/2-20/2, width: 20, height: 20))
//        self.addSubview(icoView)
        var leftImage = icoName.qianli_R_image
        if let image = UIImage(named: icoName)?.withRenderingMode(.alwaysTemplate) {
//            icoView.image = image
//            icoView.tintColor = .label // 这里可以设置你想要的填充色
            leftImage = image
        }else{
//            icoView.image = UIImage(named: icoName)
        }
        
        let edtWidth = self.bounds.width-30
        let edtHeight = self.bounds.height/2
        self.pacrUaJmER3vDJE5 = UITextField(frame: CGRect(x: 15, y: self.bounds.height/4, width: edtWidth, height: edtHeight))
        if let edit = self.pacrUaJmER3vDJE5{
            self.addSubview(edit)
            edit.placeholder = placeholder
            edit.font = .systemFont(ofSize: 15)
            edit.show_qianli_filed_lefticon(leftImage, frame: CGRect(x: 0, y: 0, width: edtHeight, height: edtHeight), imageSize: CGSize(width: 20, height: 20),tintColor:UIColor.label)
            if showclear{
                edit.clearButtonMode = .whileEditing //直接用系统自带的即可
            }
        }
    }
    
    func DdITqvtW560pCIVj(type:UIKeyboardType){
        if let edit = self.pacrUaJmER3vDJE5{
            edit.keyboardType = type
        }
    }
    
    func JRrMFFk8vXgbNlUN()->String{
        if let edit = self.pacrUaJmER3vDJE5{
            return edit.text ?? ""
        }
        return ""
    }
    
    func oC2j3DaaYowlc1xU(_ data:String){
        if let edit = self.pacrUaJmER3vDJE5{
            edit.text = data
        }
    }
}
